package biz.obake.team.touchprotector.features.proximity;

import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.SeekBar;
import android.widget.TextView;
import biz.obake.team.touchprotector.R;
import biz.obake.team.touchprotector.g.d;
import biz.obake.team.touchprotector.g.e;

public class ProximityActivity extends androidx.appcompat.app.c implements SensorEventListener {
    private TextView A;
    private SeekBar B;
    private d C = new d(this, 8, 2, "ProxSense");
    private TextView t;
    private TextView u;
    private EditText v;
    private TextView w;
    private SeekBar x;
    private TextView y;
    private SeekBar z;

    class a implements SeekBar.OnSeekBarChangeListener {
        a() {
        }

        public void onProgressChanged(SeekBar seekBar, int i, boolean z) {
            biz.obake.team.touchprotector.g.a.r("proximity_sensitivity", Integer.toString(i * 100));
            ProximityActivity.this.G();
        }

        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        public void onStopTrackingTouch(SeekBar seekBar) {
        }
    }

    class b implements SeekBar.OnSeekBarChangeListener {
        b() {
        }

        public void onProgressChanged(SeekBar seekBar, int i, boolean z) {
            biz.obake.team.touchprotector.g.a.r("proximity_sensitivity_uncovered", Integer.toString(i * 100));
            ProximityActivity.this.G();
        }

        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        public void onStopTrackingTouch(SeekBar seekBar) {
        }
    }

    class c implements SeekBar.OnSeekBarChangeListener {
        c() {
        }

        public void onProgressChanged(SeekBar seekBar, int i, boolean z) {
            biz.obake.team.touchprotector.g.a.r("proximity_false_testing", i == 0 ? "disabled" : Integer.toString(i * 100));
            ProximityActivity.this.G();
        }

        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        public void onStopTrackingTouch(SeekBar seekBar) {
        }
    }

    /* access modifiers changed from: protected */
    public void G() {
        int i;
        String str;
        String l = biz.obake.team.touchprotector.g.a.l("proximity_distance");
        boolean equals = "auto".equals(l);
        this.u.setText(biz.obake.team.touchprotector.c.w(equals ? R.string.proximity_sensitivity_activity_proximity_distance_auto : R.string.proximity_sensitivity_activity_proximity_distance).replace("{0}", l));
        if (equals) {
            l = "0";
        }
        this.v.setText(l);
        String l2 = biz.obake.team.touchprotector.g.a.l("proximity_sensitivity");
        this.w.setText(biz.obake.team.touchprotector.c.w(R.string.proximity_sensitivity_activity_proximity_time_covered).replace("{0}", Float.toString(Float.parseFloat(l2) / 1000.0f)));
        int round = Math.round(Float.parseFloat(l2) / 100.0f);
        int max = this.x.getMax();
        int i2 = 0;
        if (round < 0) {
            round = 0;
        } else if (round > max) {
            round = max;
        }
        this.x.setProgress(round);
        String l3 = biz.obake.team.touchprotector.g.a.l("proximity_sensitivity_uncovered");
        this.y.setText(biz.obake.team.touchprotector.c.w(R.string.proximity_sensitivity_activity_proximity_time_uncovered).replace("{0}", Float.toString(Float.parseFloat(l3) / 1000.0f)));
        int round2 = Math.round(Float.parseFloat(l3) / 100.0f);
        int max2 = this.z.getMax();
        if (round2 < 0) {
            round2 = 0;
        } else if (round2 > max2) {
            round2 = max2;
        }
        this.z.setProgress(round2);
        String l4 = biz.obake.team.touchprotector.g.a.l("proximity_false_testing");
        if ("disabled".equals(l4)) {
            str = biz.obake.team.touchprotector.c.w(R.string.proximity_sensitivity_activity_false_testing_disabled);
            i = 0;
        } else {
            String replace = biz.obake.team.touchprotector.c.w(R.string.proximity_sensitivity_activity_false_testing).replace("{0}", Float.toString(Float.parseFloat(l4) / 1000.0f));
            i = Math.round(Float.parseFloat(l4) / 100.0f);
            str = replace;
        }
        this.A.setText(str);
        int max3 = this.B.getMax();
        if (i >= 0) {
            i2 = i > max3 ? max3 : i;
        }
        this.B.setProgress(i2);
    }

    public void onAccuracyChanged(Sensor sensor, int i) {
    }

    public void onClickAuto(View view) {
        biz.obake.team.touchprotector.g.a.r("proximity_distance", "auto");
        G();
    }

    public void onClickCm(View view) {
        try {
            biz.obake.team.touchprotector.g.a.r("proximity_distance", Float.toString(Float.parseFloat(this.v.getText().toString())));
            G();
        } catch (NumberFormatException unused) {
            e.a(R.string.proximity_sensitivity_activity_proximity_distance_error);
        }
    }

    /* access modifiers changed from: protected */
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView((int) R.layout.proximity_sensitivity_activity);
        this.t = (TextView) findViewById(R.id.currentDistanceText);
        this.u = (TextView) findViewById(R.id.distanceText);
        this.v = (EditText) findViewById(R.id.distanceEdit);
        this.w = (TextView) findViewById(R.id.timeCoveredText);
        this.x = (SeekBar) findViewById(R.id.timeCoveredBar);
        this.y = (TextView) findViewById(R.id.timeUncoveredText);
        this.z = (SeekBar) findViewById(R.id.timeUncoveredBar);
        this.A = (TextView) findViewById(R.id.falseTestingText);
        this.B = (SeekBar) findViewById(R.id.falseTestingBar);
    }

    /* access modifiers changed from: protected */
    public void onPause() {
        super.onPause();
        this.x.setOnSeekBarChangeListener((SeekBar.OnSeekBarChangeListener) null);
        this.z.setOnSeekBarChangeListener((SeekBar.OnSeekBarChangeListener) null);
        this.C.j();
    }

    /* access modifiers changed from: protected */
    public void onResume() {
        super.onResume();
        this.x.setOnSeekBarChangeListener(new a());
        this.z.setOnSeekBarChangeListener(new b());
        this.B.setOnSeekBarChangeListener(new c());
        G();
        this.t.setText(biz.obake.team.touchprotector.c.w(R.string.proximity_sensitivity_activity_current_distance).replace("{0}", "-"));
        this.C.h();
    }

    public void onSensorChanged(SensorEvent sensorEvent) {
        this.t.setText(biz.obake.team.touchprotector.c.w(R.string.proximity_sensitivity_activity_current_distance).replace("{0}", Float.toString(sensorEvent.values[0])));
    }
}
